package com.mit.wx.wx.dto;

import com.mit.wx.util.xml.CDataConverter;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * 2018/10/13 Create by 郭文梁
 * TargetNewsMessage
 * 微信你目标图文消息
 *
 * @author 郭文梁
 * @date 2018/10/13
 */
@EqualsAndHashCode(callSuper = true)
@Data
@XStreamAlias("xml")
public class TargetNewsMessage extends TargetMessage {
    public TargetNewsMessage() {
        setMsgType(WxMessages.TYPE_NEWS);
    }

    @XStreamAlias("Articles")
    private List<Article> articles;

    public TargetNewsMessage addArticle(Article article) {
        if (articles == null) {
            articles = new ArrayList<>();
        }
        articles.add(article);
        return this;
    }

    /**
     * 2018/10/13 Create by 郭文梁
     * TargetNewsMessage
     * 微信图文消息描述
     *
     * @author 郭文梁
     * @date 2018/10/13
     */
    @Data
    @XStreamAlias("item")
    public static class Article {
        @XStreamAlias("Title")
        private String title;
        @XStreamAlias("Description")
        private String description;
        @XStreamAlias("PicUrl")
        private String picUrl;
        @XStreamAlias("Url")
        private String url;
    }
}


